﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp1
{
    class DbHelp
    {
        private static readonly string sqlserver = "server=.;database=Blogs;uid=sa;pwd=1361162012a";

        public static DataTable dataTable(String SQL)
        {
            SqlConnection sqlConnection = new SqlConnection(sqlserver);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(SQL,sqlConnection);
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(SQL,sqlConnection);
            DataTable dt = new DataTable();
            sqlDataAdapter.Fill(dt);
            return dt;
        }

       public static DataSet dataSet(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(sqlserver);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection);
            DataSet st = new DataSet();
            sqlDataAdapter.Fill(st);
            return st;
        }
      
    }
}
